package com.wmy.luckywheel.service.impl;

import com.wmy.luckywheel.entity.po.Prize;
import com.wmy.luckywheel.mapper.PrizeMapper;
import com.wmy.luckywheel.service.PrizeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author sian37  泗安
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class PrizeServiceImpl implements PrizeService {

    private final PrizeMapper prizeMapper;

    @Override
    public List<Prize> queryList() {
        return prizeMapper.queryList();
    }

    @Override
    public List<Prize> queryListAndStart() {
        return prizeMapper.queryListAndStart();
    }

    @Override
    public void add(Prize prize) {
        prize.setStatus(1);
        prize.setCreateTime(LocalDateTime.now());
        prize.setUpdateTime(LocalDateTime.now());
        prizeMapper.insert(prize);
    }

    @Override
    public void update(Prize prize) {
        prize.setUpdateTime(LocalDateTime.now());
        prizeMapper.update(prize);
    }

    @Override
    public void delete(Integer id) {
        prizeMapper.delete(id);
    }
}
